<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const sum = (...args) => {
            let total = 0;
            args.forEach((item) => (total += item));
            return total;
        };
        console.log(sum(10, 20, 30, 40, 100))
        // console.log(sum(10, 20, 30));
        let ary1 = ['张三', '李四', '王五'];
        let [s1, ...s2] = ary1;
        console.log(s1);
        console.log(s2);
        // 封装函数实现求任意个数与某个数之谁
        const getSum = (num1, ...args) => {
            let sum = 0;
            args.forEach((v) => (sum += v));
            return num1 * sum;
        }
        console.log(getSum(10, 1, 2, 3, 4));
    </script>
</body>

</html>